package teaching.io.advance;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

import teaching.io.entity.Student;

/**
 * 对象反序列化示例。
 * 
 * @author deng.zhao
 *
 */
public class ObjectInputStreamExample {
	public static void main(String[] args) {

		try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("d:/stu.dat"));) {
			List<Student> students = (List<Student>) (ois.readObject());
			for (Student student : students) {
				System.out.println(student);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

		System.out.println("DONE!");
	}
}
